refactor(deps): move zod to peerDependencies with v4-mini#278
Conversation
commit: |
There was a problem hiding this comment.
Pull request overview
This PR attempts to refactor Zod dependency management by moving it from dependencies to peerDependencies and updating all imports to use a zod/v4 subpath. However, the implementation contains a critical issue: the zod/v4 import path does not exist in Zod's package exports.
Key changes attempted:
- Move zod from
dependenciestopeerDependencieswith version range>=3.25.0 <5 - Add zod to
devDependencies(^4.1.13) for development - Replace all zod imports with
zod/v4subpath (fromzod/miniandzod)
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/schema.ts | Updates import from zod/mini to invalid zod/v4 subpath |
| src/headers.ts | Updates import from zod/mini to invalid zod/v4 subpath |
| src/feedback.ts | Updates import from zod to invalid zod/v4 subpath |
| pnpm-workspace.yaml | Moves zod from prod catalog to dev catalog, adds peer catalog entry |
| pnpm-lock.yaml | Updates lock file to reflect catalog changes |
| package.json | Moves zod from dependencies to peerDependencies and devDependencies |
| examples/tanstack-ai-integration.ts | Updates import to invalid zod/v4 subpath |
| examples/claude-agent-sdk-integration.ts | Updates import to invalid zod/v4 subpath |
| examples/claude-agent-sdk-integration.test.ts | Updates import to invalid zod/v4 subpath |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| import { tool, createSdkMcpServer } from '@anthropic-ai/claude-agent-sdk'; | ||
| import { z } from 'zod'; | ||
| import { z } from 'zod/v4'; |
There was a problem hiding this comment.
The import path zod/v4 does not appear to be a valid subpath export in Zod's package. Zod (up to version 4.1.13) exports zod (main), zod/mini, and zod/locales/*, but not zod/v4. This import will likely cause a "Module not found" error at runtime.
The standard import should be import { z } from 'zod' for the main Zod API. If version 4-specific APIs are needed, they are available through the standard zod import when using Zod 4.x.
| import { z } from 'zod/v4'; | |
| import { z } from 'zod'; |
src/schema.ts
Outdated
| @@ -1,4 +1,4 @@ | |||
| import { z } from 'zod/mini'; | |||
| import { z } from 'zod/v4'; | |||
There was a problem hiding this comment.
The import path zod/v4 does not appear to be a valid subpath export in Zod's package. Zod (up to version 4.1.13) exports zod (main), zod/mini, and zod/locales/*, but not zod/v4. This import will likely cause a "Module not found" error at runtime.
The standard import should be import { z } from 'zod' for the main Zod API. If version 4-specific APIs are needed, they are available through the standard zod import when using Zod 4.x.
| import { z } from 'zod/v4'; | |
| import { z } from 'zod'; |
src/headers.ts
Outdated
| @@ -1,4 +1,4 @@ | |||
| import { z } from 'zod/mini'; | |||
| import { z } from 'zod/v4'; | |||
There was a problem hiding this comment.
The import path zod/v4 does not appear to be a valid subpath export in Zod's package. Zod (up to version 4.1.13) exports zod (main), zod/mini, and zod/locales/*, but not zod/v4. This import will likely cause a "Module not found" error at runtime.
The standard import should be import { z } from 'zod' for the main Zod API. If version 4-specific APIs are needed, they are available through the standard zod import when using Zod 4.x.
| import { z } from 'zod/v4'; | |
| import { z } from 'zod'; |
examples/tanstack-ai-integration.ts
Outdated
| import { chat } from '@tanstack/ai'; | ||
| import { openai } from '@tanstack/ai-openai'; | ||
| import { z } from 'zod'; | ||
| import { z } from 'zod/v4'; |
There was a problem hiding this comment.
The import path zod/v4 does not appear to be a valid subpath export in Zod's package. Zod (up to version 4.1.13) exports zod (main), zod/mini, and zod/locales/*, but not zod/v4. This import will likely cause a "Module not found" error at runtime.
The standard import should be import { z } from 'zod' for the main Zod API. If version 4-specific APIs are needed, they are available through the standard zod import when using Zod 4.x.
| import { z } from 'zod/v4'; | |
| import { z } from 'zod'; |
| import process from 'node:process'; | ||
| import { query, tool, createSdkMcpServer } from '@anthropic-ai/claude-agent-sdk'; | ||
| import { z } from 'zod'; | ||
| import { z } from 'zod/v4'; |
There was a problem hiding this comment.
The import path zod/v4 does not appear to be a valid subpath export in Zod's package. Zod (up to version 4.1.13) exports zod (main), zod/mini, and zod/locales/*, but not zod/v4. This import will likely cause a "Module not found" error at runtime.
The standard import should be import { z } from 'zod' for the main Zod API. If version 4-specific APIs are needed, they are available through the standard zod import when using Zod 4.x.
| import { z } from 'zod/v4'; | |
| import { z } from 'zod'; |
0560439 to
e2e883f
Compare
- Move zod from dependencies to peerDependencies (>=3.25.0 <5) - Use zod/v4-mini subpath for smaller bundle size in schema/headers - Use zod/v4 subpath in feedback.ts (requires .transform/.refine) - Add zod to devDependencies and examples for development/testing This allows users to bring their own zod version (3.25+ or 4.x) while ensuring compatibility with AI SDK's zod peer dependency. The v4-mini variant reduces bundle size for simple schemas.
e2e883f to
11108bc
Compare
Summary
>=3.25.0 <5)zod/v4-minisubpath for smaller bundle size in schema/headerszod/v4subpath in feedback.ts (requires.transform/.refine)Why
This allows users to bring their own zod version (3.25+ or 4.x) while ensuring compatibility with AI SDK's zod peer dependency. The
zod/v4-minivariant reduces bundle size for simple schemas.Test plan